var version = '1.2.0';

self.__uri = function(src) {
	return src
};

importScripts(__uri('/static/js/lib/sw-toolbox.js'));
importScripts(__uri('/static/js/lib/sw/monitor.js'));

self.addEventListener('install', function(event) {
	event.waitUntil(self.skipWaiting());
});
self.addEventListener('activate', function(event) {
	event.waitUntil(self.clients.claim());
});

toolbox.router.get('/:module/sw', toolbox.networkOnly);
toolbox.router.get('/static/(.*)', toolbox.cacheFirst);
toolbox.router.get('/(.*)', toolbox.networkFirst);
toolbox.router.get('/(.*)', function(request, values, options) {
	// 跨域，针对微信添加额外的头
	var newRequest = new Request(request, {
		headers: {}
	});
	return toolbox.cacheFirst.apply(this, [newRequest, values, options]);
}, {
	origin: /^https?:\/\/at\.alicdn\.com/,
	cache: {
		name: 'font_1457169990_5499172',
		maxEntries: 10,
		maxAgeSeconds: 60 * 60 * 24 * 7
	}
});